package ui.grafic;

import java.awt.Graphics;
import java.util.Vector;

import miniworld.PhysicalNetwork;
import datatypes.Edge;
import datatypes.Host;
import datatypes.HostDescription;
import datatypes.ScenarioDescription;

public class PhysNetworkExecutionGrafic extends NetworkExecutionGrafic {
	
	private ScenarioDescription desc;
	private int range = -1;

	public PhysNetworkExecutionGrafic(ScenarioDescription desc) {
		super(desc.getRosterWidth(), desc.getRosterHeight(), desc.getRange());
		super.skalierungsfaktor = 4;
		this.range = desc.getRange();
		this.desc = desc;
		super.boldPoints = true;
	}

//	private void drawEdges(ScenarioDescription scenDesc, PhysicalNetwork phyNet) {
//		for (int i = 0; i < phyNet.getEdges().size(); i++) {
//			HostDescription node1 = scenDesc.getHostDescription(phyNet.getEdges().get(i).getFirstHost().getID());
//			HostDescription node2 = scenDesc.getHostDescription(phyNet.getEdges().get(i).getSecondHost().getID());
//			if (node1 != null && node2 != null) {
//				edges.add(new Line(node1.getX(), node1.getY(), node2.getX(), node2.getY()));
//			}
//		}
//		this.repaint();
//	}
	
	public void addEdge (Edge edge){
		HostDescription node1 = desc.getHostDescription(edge.getFirstHost().getID());
		HostDescription node2 = desc.getHostDescription(edge.getSecondHost().getID());		
		if (node1 != null && node2 != null) {
			edges.add(new Line(node1.getX()+range, node1.getY()+range, node2.getX()+range, node2.getY()+range));
			lineMap.put(edge.getEdgeID(), edges.lastElement());
		}
		this.updateUI();
	}

	public void removeEdge(Edge edge) {
		super.removeLine(edge.getEdgeID());
	}

	public void addNode(int hostId) {
		HostDescription node1 = desc.getHostDescription(hostId);
		super.addPoint(node1.getX(), node1.getY(), hostId+"");
		this.updateUI();
	}

	public void removeNode(int hostId) {
		HostDescription node1 = desc.getHostDescription(hostId);
		super.removePoint(node1.getX(), node1.getY());
		this.updateUI();
	}
	
	
	


}